<?php
	include_once("config.php");
	
	// step 1: gather the information and assemble a MySQL query
	// TO-DO: Inject server-side session code to detect user's login
	//$username = "temp"; 
	session_start();
	$username = $HTTP_SESSION_VARS['username']; 
	
	$playlist = $_GET['playlist']; 
	$sql = "select * from ajax_video where username='$username' and
										   playlist = '$playlist'";
	db_connect();
	$row = exec_query($sql);
	
	$json_text = $row['json'];
	
	echo $json_text; 
	/* step 2: parse the results and create a JSON object to pass onto the Dojo ItemFileWriteStore
	$json_text = "{ identifier: 'position',
					label: 'song',
					items: [";
	$position = 0;
	$row = mysql_fetch_assoc($result);
	$current_entry = "{ position: '$position', song: '".$row['song']."', artist: '".$row['artist']."'}";
	//$current_entry = "{ position: '$position', song: '".$row['song']."', artist: '".$row['artist']."', id: '".$row['id']."'}";
	$json_text = $json_text.$current_entry; 
	
	while ($row = mysql_fetch_assoc($result)) {
		$position++; 
		$current_entry = ",{ position: '$position', song: '".$row['song']."', artist: '".$row['artist']."', id: '".$row['id']."'}";
		$json_text = $json_text.$current_entry; 
	}
	
	$json_text = $json_text."]}"; 
	
	// step 3: output it
	echo $json_text;*/ 
?>